<template>
    <view class="container">
        <view class="main">
            <uni-load-more status="loading" v-if="isloadding"></uni-load-more>
            <view>
                <scroll-view scroll-y>
                    <view v-if="data.length > 0">
                        <view
                            class="list"
                            v-for="(item, index) in data"
                            :key="index"
                            @click="
                                goUrl(
                                    '/pages_supplier/packet/order/deliverGoods?buyOrdId=' +
                                        buyOrdId +
                                        '&ordId=' +
                                        item.OrderId,
                                )
                            ">
                            <view class="flex-between list-top">
                                <view class="flex-start">
                                    <view class="top-state">销售订单：{{ item.Sn }}</view>
                                </view>
                            </view>
                            <view class="list-main">
                                <view class="order-item-main">
                                    <view class="order-item-imgs">
                                        <view
                                            class="img-item"
                                            v-for="(imgitem, indeximg) in item.OrderDetailTBList"
                                            :key="indeximg"
                                            v-if="indeximg < 3">
                                            <image
                                                mode="aspectFill"
                                                :src="easyGetImgUrl(imgitem.ProductImage)"
                                                class="order-item-img"></image>
                                            <text class="text-num">x{{ imgitem.Amount }}{{ imgitem.UnitName }}</text>
                                        </view>
                                        <view class="order-item-name" v-if="item.OrderDetailTBList.length == 1">{{
                                            item.OrderDetailTBList[0].Name
                                        }}</view>
                                        <uni-icons type="more" v-if="item.OrderDetailTBList.length > 3"></uni-icons>
                                    </view>
                                    <view class="right-box">
                                        <view class="num-box">
                                            <text class="order-desc">共{{ item.OrderDetailTBList.length }}种</text>
                                        </view>
                                        <uni-icons type="arrowright" size="20" customIcons="icon-gray-1"></uni-icons>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <view class="mescroll-empty" v-else>
                        <image src="/static/img/empty.png"></image>
                        <view>~ 暂无数据 ~</view>
                    </view>
                </scroll-view>
            </view>
        </view>
    </view>
</template>

<script>
import deliverList from "@/pages_supplier/components/order/deliver-list.vue"
import tabBarTwo from "@/pages_supplier/components/common/tab-bar-two.vue"
import storage from "@/uni-sub-base/utils/storage.js"
import { GetOrderSendListByBuyId } from "@/pages_supplier/service/api/buyOrder.js"
export default {
    components: {
        deliverList,
        tabBarTwo,
    },
    data() {
        return {
            buyOrdId: "",
            optEmpty: {
                icon: "/static/img/empty.png", // 图标路径 (建议放入static目录, 如 /static/img/mescroll-empty.png )
                tip: "~ 暂无数据 ~", // 空提示
            },
            isloadding: true,
            tabIndex: 0,
            listHeight: "", //list所需高度
            loadOk: false,
            searchKey: "",
            orderId: "",
            data: [],
        }
    },
    onLoad(e) {
        this.buyOrdId = e.buyOrdId
    },
    onShow() {},
    mounted() {
        this.getList()
    },
    methods: {
        getList() {
            let path = "?buyOrdId=" + this.buyOrdId + "&ordId=0"
            GetOrderSendListByBuyId(path).then((res) => {
                if (res.State == 1) {
                    this.isloadding = false
                    this.data = res.Data.SaleOrderList
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
        goUrl(url) {
            this.easyGoTo(url)
        },
    },
}
</script>

<style lang="scss" scoped>
.container {
    padding-bottom: $app-item-padding;
}

.order-item {
    padding: $app-item-padding;
    .order-submit-item {
        display: flex;
        flex-direction: column;
        background: #ffffff;
        padding: 24rpx;
        margin-bottom: 24rpx;
        border-radius: 16rpx;
        .item-top {
            display: flex;
            flex-direction: row;

            .product-img {
                width: 120rpx;
                height: 120rpx;
                border-radius: $border-radius-10;
                margin-right: 20rpx;
            }

            .product-info {
                display: flex;
                flex-direction: column;
                flex: 1;

                .product-name {
                    font-weight: 700;
                    font-size: $font-size-28;
                    color: $app-color-text-mian;
                    flex: 1;
                    display: flex;
                    align-items: center;
                    margin-bottom: 14rpx;
                }

                .policy-text {
                    flex: 1;
                    padding-right: 12rpx;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    font-weight: normal;
                    display: flex;
                    color: #fa6400;
                }

                .arrow {
                    border: solid #333333;
                    border-width: 0 1px 1px 0;
                    padding: 3px;
                }

                .arrow-down {
                    margin-top: -4rpx;
                }

                .btn {
                    flex-direction: row;
                    font-size: $font-size-20;
                    margin-left: 0;
                }
            }

            .btn-yellow-hollow {
                height: 48rpx;
                margin-bottom: 20rpx;
                width: auto;
                border-radius: 4rpx;
                border-color: rgba(0, 0, 0, 0);
                background: #ffffff;
                border: 1rpx solid #fa6400;

                .icon {
                    width: 40rpx;
                    height: 40rpx;
                    margin-right: 10rpx;
                }
            }
        }

        .item-center {
            background: #f7f7f7;
            padding: 14rpx 24rpx;
            margin-top: 20rpx;

            .item-cell {
                display: flex;
                flex-direction: row;
                justify-content: flex-end;
                margin-bottom: 8rpx;

                .label {
                    display: flex;
                    flex: 1;
                    color: $app-color-text-tip;
                }

                .value {
                    display: flex;
                    justify-content: flex-end;
                }
            }
        }

        .item-bottom {
            border-radius: $border-radius-10;
            padding: $app-page-padding;
            background: $app-color-input-bg;

            input {
                font-size: $font-size-24;
                color: $app-color-text-tip;
            }
        }
    }
}
.product-num {
    color: $color-gray-1;
    font-size: 28rpx;
}
.pro-item {
    display: flex;
    flex-direction: row;

    .left {
        display: flex;
        flex-direction: column;
        flex: 1;
        margin-top: 4rpx;

        .label {
            font-size: 26rpx;
            color: $app-color-text-tip;
            padding: 6rpx 0;

            text {
                font-size: 26rpx;
            }
            .specification {
                font-size: 30rpx;
                color: $color-gray-1;
            }
        }
        .price-bold {
            color: #000;
            font-size: 32rpx;
            font-weight: bold;
            padding-right: 14rpx;
        }
    }

    .right {
        display: flex;
        align-items: center;

        .price-text {
            font-size: $font-size-28;
            color: $color-gray-1;
        }
    }
}
.list {
    background: #fff;
    margin: 24rpx 24rpx 0rpx 24rpx;
    border-radius: 16rpx;
    .list-top {
        padding: $app-item-padding;
        border-bottom: 1rpx solid #ebebeb;
        .top-state {
            padding-left: 12rpx;
            font-size: 28rpx;
            color: $color-gray-2;
        }
        .p-r-12 {
            padding-right: 12rpx;
        }
    }
    .list-main {
        padding: $app-item-padding;
    }
    .list-bottom {
        display: block;
        padding: 0 $app-item-padding $app-item-padding $app-item-padding;
    }
}
.order-item-main {
    display: flex;
    flex: 1;
    flex-direction: row;
}

.order-item-imgs {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: center;

    .img-item {
        position: relative;
        margin-right: 24rpx;
        display: flex;
        align-items: center;

        .order-item-img {
            display: flex;
            width: 120rpx;
            height: 120rpx;
            // border: 1px solid $app-color-main;
            border-radius: 8rpx;
        }

        .text-num {
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 40rpx;
            border-bottom-left-radius: 10rpx;
            border-bottom-right-radius: 10rpx;
            color: $color-white;
            background: rgba($color-black, 0.3);
            font-size: $font-size-24;
        }
    }
    .order-item-name {
        flex: 1;
        font-size: 28rpx;
        color: $color-gray-1;
        display: flex;
        align-items: center;
    }
}
.right-box {
    display: flex;
    flex-direction: row;
    align-items: center;

    .num-box {
        display: flex;
        flex-direction: column;
        margin-right: 16rpx;

        text {
            margin-bottom: 4rpx;

            &:last-child {
                margin-bottom: 0;
            }
        }
    }
}
.pop-pro-list {
    background: #f1f1f1;
    border-radius: 24rpx 24rpx 0 0;
    height: 70vh;
    .pop-header {
        display: flex;
        flex-direction: row;
        height: 88rpx;
        align-items: center;
        justify-content: center;
        border-radius: 24rpx 24rpx 0 0;
        background: #ffffff;

        .icon-close {
            position: absolute;
            right: 24rpx;
            color: $color-gray-3;
        }

        .text {
            font-size: $font-size-28;
            font-weight: 700;
        }
    }

    .scroll {
        height: 100%;
        background: #f1f1f1;
    }
}
.mescroll-empty {
    box-sizing: border-box;
    width: 100%;
    padding: 50px 25px;
    text-align: center;
    image {
        width: 140px !important;
        height: 98px !important;
    }
    view {
        margin-top: 10px;
        font-size: 12px;
        color: gray;
    }
}
.detail-main {
    padding: $app-item-padding $app-item-padding 0;
    .detail-list {
        background: #ffffff;
        border-radius: 12rpx;
        margin-bottom: 24rpx;
        padding: $app-item-padding;
        display: flex;
        image {
            width: 160rpx;
            height: 160rpx;
            margin-right: 16rpx;
        }
        .d-list-main {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            .d-list-name,
            .d-list-unit {
                font-size: 28rpx;
                color: #333333;
            }
            .d-list-spec {
                font-size: 28rpx;
                color: #999999;
            }
            .d-list-price {
                font-size: 32rpx;
                font-weight: bold;
                color: #252528;
                padding-right: 14rpx;
            }
        }
    }
}
</style>
